package chapter03

import org.apache.log4j.{Level, Logger}
import org.apache.spark.{SparkConf, SparkContext}

object Test32_save {
  def main(args: Array[String]): Unit = {
    Logger.getLogger("org.apache.spark").setLevel(Level.WARN)
    val ads = new SparkConf().setMaster("local[*]").setAppName("save")
    val sc = new SparkContext(ads)
    sc.setLogLevel("warn")
    //保存成SequenceFile
    val value = sc.makeRDD(List(("a", 88), ("b", 95), ("a", 91),
      ("b", 93), ("a", 95), ("b", 98)),2)
//    value.saveAsSequenceFile("input/abc")
    //读取文件
    val value1 = sc.sequenceFile[String, Int]("input/abc")
    println(value1.collect().toList)
    //保存成objectFile
    val value2 = sc.makeRDD(List(1, 2, 3, 4, 5, 6),2)
//    value2.saveAsObjectFile("input/bcd")
    val value3 = sc.objectFile[Int]("input/bcd")
    println(value3.collect().toList)
  }
}
